package com.ych.controller;

import com.ych.beans.Message;
import com.ych.beans.Sensor;
import com.ych.service.SensorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/asset/sensor")
public class SensorController {
    @Autowired
    SensorService service;
    @PostMapping
    public Message addSensor(@RequestBody Sensor sensor){
        return service.addSensor(sensor);
    }

    @DeleteMapping("/{id}")
    public Message deleteSensor(@PathVariable Integer id){
        return service.deleteSensor(id);
    }

    @PutMapping
    public Message updateSensor(@RequestBody Sensor sensor){
        return service.updateSensor(sensor);
    }

    @GetMapping
    public Message selectSensor(@RequestParam Integer pageNo,@RequestParam(required = false) String key){
        return service.selectSensor(pageNo,key);
    }
}
